#include "lm89.h"


void get_temp(int *temp, TWI_Master_t *temp_sensor){
	int8_t buffer=0;
	uint8_t write_buffer[4] = {TEMP_REGISTER, 0x55, 0x33, 0x22};

	while(temp_sensor->status != TWIM_STATUS_READY);
	//if(temp_sensor->status != TWIM_STATUS_READY){
		TWI_MasterWriteRead(temp_sensor, ADDRESS, write_buffer, 1, 1);
	//}
	while(temp_sensor->status != TWIM_STATUS_READY);

	buffer = temp_sensor->readData[0];
	//Minus 1 adjustment for offset
	*temp = buffer - 4;
	if(*temp!=0){
		//PORTA.OUT ^= 3;
	}

}

